﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using CE.User;
using CE.PersonalAccident;
using CE.Global;
using CE.AreaCountry;
using CE.TravelInsurance;
using CE.Mail;
using CE.Company;
using CE.Database;

public partial class travel_insurance_travel_quote : System.Web.UI.Page
{
    private Int32 RowCount = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (CE.Global.General.isMobileBrowser())
            {
                string _cxmobile = CE.Configuration.MyConfigurationManager.GetAppSettingValue("CXMobileURL.Travel");
                Response.Redirect(_cxmobile);
            }

            if (Request.QueryString["pid"] != null)
            {
                if (Request.QueryString["pid"].ToString() != "")
                {
                    CXDecryption.Decryption cxd = new CXDecryption.Decryption();
                    string decPid = cxd.Decrypt(Request.QueryString["pid"].ToString());
                    inputPID.Value = decPid;

                    divMainRight.Visible = false;

                    if (decPid == "36")
                    {
                        imgTravelBanner.Src = "/images/promo/fbanner-ace.jpg";
                        imgTravelBanner.Alt = "ACE Promotion";
                        divACERight.Visible = true;
                    }
                    else if (decPid == "29")
                    {
                        imgTravelBanner.Src = "/images/promo/fbanner-liberty.jpg";
                        imgTravelBanner.Alt = "Liberty Promotion";
                        divLibertyRight.Visible = true;
                    }
                    else if (decPid == "23")
                    {
                        imgTravelBanner.Src = "/images/promo/fbanner-hsbc.jpg";
                        imgTravelBanner.Alt = "HSBC Promotion";
                        divHSBCRight.Visible = true;
                    }
                    else if (decPid == "30")
                    {
                        imgTravelBanner.Src = "/images/promo/fbanner-etiqa-t.jpg";
                        imgTravelBanner.Alt = "Etiqa Promotion";
                        divEtiqaRight.Visible = true;
                    }
                }
            }
            else
            {
                inputPID.Value = "";
            }

            LoadCountries();
            LoadRegion();
            ChangeControlSetting();
            ChangeDateSetting();

            if (Request.UrlReferrer != null)
            {
                if (Request.UrlReferrer.AbsolutePath.ToString().ToLower() != "/travel-flights/results.aspx"
                    && Request.UrlReferrer.AbsolutePath.ToString().ToLower() != "/travel-insurance/results.aspx"
                    && Request.UrlReferrer.AbsolutePath.ToString().ToLower() != "/travel-insurance/results-details.aspx")
                {
                    Session[General.TAId] = null;
                }
            }
            //else
            //{
            //    Session[General.TAId] = null;
            //}


            if (Session[General.TAId] != null)
            {
                ShowTADetails(Convert.ToInt64(Session[General.TAId].ToString()));
                //ChangeScenario2(this, null);
            }

            General.ClearAllSession(this.Page, "TA");


            //LogUserViewedHistory();
            Session[General.ViewedDetailsId] = LogUserViewedHistory().ToString();

            //Page.GetPostBackEventReference(invisiBtn);

            //usrS7Child1DOB.Attributes.Add("onmouseover", "JT_ShowTwo('/tooltips/child_age.htm?width=550', '" + usrS7Child1DOB.ClientID + "', 'Child Age'); return true;");
            //usrS7Child1DOB.Attributes.Add("onblur", "$('#JT').remove();ShowValidationEffect('" + usrS7Child1DOB.ClientID + "','" + rfvRenewNCD.ClientID + "');");

            //if (Session[General.UserId] == null)
            //{
            //    divUserInfo.Visible = true;

            //    //txtEmail.Attributes.Add("onfocus", "JT_ShowTwo('/tooltips/username.htm?width=250', '" + txtEmail.ClientID + "', 'CompareXpress User Account'); return true;");
            //    txtEmail.Attributes.Add("onblur", "$('#JT').remove();ShowValidationEffectTwo('" + txtEmail.ClientID + "','" + rfvEmail.ClientID + "','" + cxvEmail.ClientID + "')");
            //    txtFullName.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtFullName.ClientID + "','" + rfvFullName.ClientID + "','" + revFullName.ClientID + "')");
            //}


        }


        if (Convert.ToInt32(Session[CE.Global.General.UserTypeId]) ==
         Convert.ToInt32(CE.Global.CEUserType.Customer))
        {
            //ShowUserDetails();
        }
        else if (Convert.ToInt32(Session[CE.Global.General.UserTypeId]) ==
            Convert.ToInt32(CE.Global.CEUserType.Provider))
        {
            //ShowUserDetails();
            hplAppDetails.Visible = false;
        }

        Session[General.TACustomerAge] = null;


    }

    private void LoadRegion()
    {
        DataTable dtRegionArea = General.GetComboItem("RegionArea", true);

        ddlDestRegion.DataSource = dtRegionArea;
        ddlDestRegion.DataTextField = dtRegionArea.Columns[0].ColumnName.ToString();
        ddlDestRegion.DataValueField = dtRegionArea.Columns[1].ColumnName.ToString();
        ddlDestRegion.DataBind();
        ddlDestRegion.Items.Insert(0, new ListItem("Select", "-1"));

        ddlDestRegion.Attributes.Add("onblur", "ShowValidationEffect('" + ddlDestRegion.ClientID + "','" + rfvDestRegion.ClientID + "');");

    }

    private void LoadCountries()
    {
        //DataTable dtCountry = General.GetComboItem("Country", true);

        //Sakthi on 16 Dec 2010  -- Start
        DataTable dtTempCountry = General.GetComboItem("Country", true);
        DataTable dtCountry = new DataTable();

        if (dtTempCountry.Rows.Count > 0)
        {
            DataSet dsCountry = new DataSet();
            for (Int16 i = 0; i < dtTempCountry.Rows.Count; i++)
            {
                if (dtTempCountry.Rows[i]["CountryId"].ToString() == "185")
                {
                    dsCountry = General.RemoveRow(dtTempCountry, i);
                    dtCountry = dsCountry.Tables[0];
                }
                else
                {
                    dtCountry = dtTempCountry;
                }
            }
        }//Sakthi on 16 Dec 2010  -- End

        ddlDestCountry.DataSource = dtCountry;
        ddlDestCountry.DataTextField = dtCountry.Columns[0].ColumnName.ToString();
        ddlDestCountry.DataValueField = dtCountry.Columns[1].ColumnName.ToString();
        ddlDestCountry.DataBind();
        ddlDestCountry.Items.Insert(0, new ListItem("Select", "-1"));

        ddlDestCountry.Attributes.Add("onblur", "ShowValidationEffect('" + ddlDestCountry.ClientID + "','" + rfvDestCountry.ClientID + "');");

    }

    private Int64 LogUserViewedHistory()
    {
        UserViewHistoryDB _userviewdb = new UserViewHistoryDB();
        return _userviewdb.LogViewedHistory("TA", Request, "Travel Insurance travel quote.");
    }

    //private Int64 CheckAndCreateAndSendMailToUser()
    //{
    //    Int64 _retVal = 0;
    //    Account _account = new Account();
    //    AccountDB _accountdb = new AccountDB();

    //    if (!_accountdb.IsAlreadyExist(txtEmail.Text, Convert.ToInt32(CE.Global.CEUserType.Customer)))
    //    {
    //        Profile _userprofile = new Profile();
    //        ProfileDB _userprofiledb = new ProfileDB();
    //        Contact _contact = new Contact();
    //        ContactDB _contactdb = new ContactDB();

    //        long _result = -1;

    //        _account.Email = txtEmail.Text.ToLower();
    //        Random _random = new Random();
    //        string _authcode = "";
    //        //Sakthi on 21 Jan 2011
    //        //_authcode = "T" + _random.Next(9).ToString() + _random.Next(9).ToString() + _random.Next(9).ToString() + _random.Next(9).ToString() + _random.Next(9).ToString();
    //        _authcode = _random.Next(9).ToString() + _random.Next(9).ToString() + _random.Next(9).ToString() + _random.Next(9).ToString() + _random.Next(9).ToString();
    //        _account.AuthCode = _authcode;

    //        _account.UserId = "CEUSERAUTOIDTI";
    //        _account.UserTypeId = Convert.ToInt32(CE.Global.CEUserType.Customer);
    //        _account.IsAcceptTC = true;
    //        _account.Status = true;
    //        _account.RefCEUserID = -1;

    //        _result = _accountdb.Insert(_account);
    //        _account.CEID = _result;

    //        _retVal = _result;

    //        if (_result > 0)
    //        {
    //            _userprofile.SurName = ""; // Server.HtmlEncode(txtFullName.Text.ToUpper());

    //            //DateTime _dtDOB = new DateTime(1900, 1, 1);
    //            //_userprofile.DOB = 
    //            //if (ddlPolicyType.Text == "IND")
    //            //{
    //            //    _userprofile.DOB = usrS1Birthday.GetDate();
    //            //}
    //            //else if (ddlPolicyType.Text == "INS")
    //            //{
    //            //    _userprofile.DOB = usrS2Birthday.GetDate();
    //            //}
    //            _userprofile.DOB = new DateTime(1900, 1, 1);
    //            _userprofile.RefCEUserId = _account.CEID;
    //            _userprofile.Status = "NEW";
    //            _result = _userprofiledb.Insert(_userprofile);

    //            _contact.Email = _account.Email;
    //            _contact.Mobile = txtMobileNo.GetPhoneNo();

    //            _contact.Status = true;
    //            _contact.RefCEUserId = _account.CEID;
    //            _result = _contactdb.Insert(_contact);

    //            if (_result > 0)
    //            {
    //                //Send Email Travel
    //                SaveUserLoginInformation(_account.CEID, _account.UserTypeId);
    //                Session[CE.Global.General.UserId] = _account.CEID;
    //                Session[CE.Global.General.UserTypeId] = _account.UserTypeId;
    //                Session[CE.Global.General.UserEmail] = _account.Email;
    //                Session[CE.Global.General.UserPhoneNo] = _contact.Mobile;
    //                Session[CE.Global.General.StartTime] = CE.Global.General.GetUTCDateTime().ToString();
    //                if (_userprofile.FirstName != string.Empty)
    //                {
    //                    Session[CE.Global.General.UserName] = _userprofile.SurName + " " + _userprofile.FirstName;
    //                }
    //                else
    //                {
    //                    Session[CE.Global.General.UserName] = _userprofile.SurName;
    //                }
    //                Session[CE.Global.General.UserProfileAndContactComplete] = "0";
    //                if (!SendMailToUser(_account.CEID, false, txtEmail.Text, Session[CE.Global.General.UserName].ToString(), _authcode))
    //                {
    //                    _account.Info1 = "0";
    //                    _account.Info2 = "New User - Travel Insurance";
    //                    _accountdb.Insert(_account);
    //                }
    //            }
    //        }
    //    }
    //    else
    //    {
    //        //Existing Email
    //        _account = _accountdb.CheckEmail(txtEmail.Text, Convert.ToInt32(CE.Global.CEUserType.Customer));
    //        if (_account != null)
    //        {
    //            if (!SendMailToUser(_account.CEID, true, txtEmail.Text, txtFullName.Text.ToUpper(), ""))
    //            {
    //                //_account.Info1 = "0";
    //                //_account.Info2 = "First Quote - Travel Insurance";
    //                //_accountdb.Insert(_account);
    //            }
    //            _retVal = _account.CEID;
    //        }
    //    }

    //    _account = null;
    //    _accountdb = null;

    //    return _retVal;
    //}

    protected bool SaveUserLoginInformation(Int64 CEID, int UserTypeId)
    {
        LoginHistory _loghis = new LoginHistory();
        LoginHistoryDB _loghisdb = new LoginHistoryDB();
        LoginInformation _loginfo = new LoginInformation();
        LoginInformationDB _loginfodb = new LoginInformationDB();

        _loghis.CEID = CEID;
        _loghis.UserTypeId = UserTypeId;
        _loghis.StartTime = CE.Global.General.GetUTCDateTime();
        _loghis.EndTime = CE.Global.General.GetUTCDateTime();
        _loghis.IsExpired = false;
        _loghis.Status = "LOGIN";

        _loghis.LoginHisId = _loghisdb.Insert(_loghis);

        if (_loghis.LoginHisId > 0)
        {
            Session[CE.Global.General.LoginHistoryId] = _loghis.LoginHisId.ToString();
            _loginfo.CEID = CEID;
            _loginfo.UserTypeId = UserTypeId;
            _loginfo.LogHisId = _loghis.LoginHisId;

            _loginfo.Browser = Request.Browser.Browser;
            _loginfo.BrowserType = Request.Browser.Type;
            _loginfo.BrowserVersion = Request.Browser.Version;
            _loginfo.MajorVersion = Request.Browser.MajorVersion.ToString();
            _loginfo.MinorVersion = Request.Browser.MinorVersionString;

            _loginfo.JavaScript = Request.Browser.JavaScript;
            _loginfo.VBScript = Request.Browser.VBScript;
            _loginfo.ActivX = Request.Browser.ActiveXControls;
            _loginfo.Frames = Request.Browser.Frames;
            _loginfo.Tables = Request.Browser.Tables;
            _loginfo.Cookies = Request.Browser.Cookies;
            _loginfo.DotNetVersion = Request.Browser.ClrVersion.ToString();
            _loginfo.JavaApplet = Request.Browser.JavaApplets;

            _loginfo.Win16 = Request.Browser.Win16;
            _loginfo.Win32 = Request.Browser.Win32;
            _loginfo.Platform = Request.Browser.Platform;
            _loginfo.UserAgent = Request.UserAgent.ToString();
            _loginfo.IpAddress = Request.UserHostAddress;
            _loginfo.HostName = Request.UserHostName;

            //_loginfo.Info1 = Request.Browser.Tables;
            //_loginfo.Info2 = Request.Browser.Platform;
            _loginfo.UserInfoId = _loginfodb.Insert(_loginfo);
        }

        return _loginfo.UserInfoId > 0;

    }

    protected void imgbtnSearch_Click(object sender, EventArgs e)
    {
        CheckValidation();
        if (CheckTravelDateValid())
        {
            if (Page.IsValid)
            {
                if (Session[General.TAId] != null)
                {
                    Cache.Remove("TAResultsQuotes" + Session[General.TAId].ToString());
                }

                Int64 countryid = 0;
                Int64 areaid = 0;
                string coveragelevel = "";
                Int32 duration = 0;
                DateTime startdate = new DateTime(1900, 1, 1);
                DateTime enddate = new DateTime(1900, 1, 1);
                Int32 childage = 0;
                Int32 adultage1 = 0;
                Int32 adultage2 = 0;
                Int32 adultage3 = 0;
                Int32 adultage4 = 0;

                Int32 noofadults = 0;
                DateTime dobadult1 = CE.Global.General.GetUTCDateTime();
                DateTime dobadult2 = CE.Global.General.GetUTCDateTime();
                DateTime dobadult3 = CE.Global.General.GetUTCDateTime();
                DateTime dobadult4 = CE.Global.General.GetUTCDateTime();
                Int32 noofchilds = 0;
                DateTime dobchild1 = CE.Global.General.GetUTCDateTime();
                DateTime dobchild2 = CE.Global.General.GetUTCDateTime();
                DateTime dobchild3 = CE.Global.General.GetUTCDateTime();
                DateTime dobchild4 = CE.Global.General.GetUTCDateTime();
                DateTime dobchild5 = CE.Global.General.GetUTCDateTime();
                DateTime dobchild6 = CE.Global.General.GetUTCDateTime();

                #region scenario logic
                //Response.Write("<script>window.alert('ok')</script>");
                coveragelevel = ddlCoverage.SelectedValue;

                if (ddlPolicyType.Text == "IND")
                {

                    adultage1 = ComputeAge(usrBirthday.GetDate()); //ComputeAge(usrS1Birthday.GetDate());
                    dobadult1 = usrBirthday.GetDate(); //usrS1Birthday.GetDate();
                    noofadults = 1;
                    noofchilds = 0;                    

                    if (ddlTripType.SelectedValue == "S")
                    {
                        //Scenario 1
                        countryid = Convert.ToInt64(ddlDestCountry.SelectedValue.ToString());//Convert.ToInt64(ddlS1DestCountry.SelectedValue.ToString());

                        //duration = ComputeDuration(usrTravelStartDate.GetDate(), usrTravelEndDate.GetDate()); //ComputeDuration(usrS1TravelStartDate.GetDate(), usrS1TravelEndDate.GetDate());
                        inputFrom.Value = Request.Form["from"].ToString().Trim();
                        string[] startdateformatted = Request.Form["from"].ToString().Trim().Split('/');
                        string startdate1 = startdateformatted[2] + "-" + startdateformatted[1] + "-" + startdateformatted[0];

                        inputTo.Value = Request.Form["to"].ToString().Trim();
                        string[] enddateformatted = Request.Form["to"].ToString().Trim().Split('/');
                        string enddate1 = enddateformatted[2] + "-" + enddateformatted[1] + "-" + enddateformatted[0];

                        DateTime dtStart = Convert.ToDateTime(startdate1);
                        DateTime dtEnd = Convert.ToDateTime(enddate1);

                        duration = ComputeDuration(dtStart, dtEnd);
                        startdate = dtStart; // usrTravelStartDate.GetDate();
                        enddate = dtEnd; // usrTravelEndDate.GetDate();
                    }
                    else
                    {
                        //Scenario 2
                        areaid = Convert.ToInt64(ddlDestRegion.SelectedValue.ToString()); //Convert.ToInt64(ddlS2DestRegion.SelectedValue.ToString());
                        //startdate = usrPolicyComDate.GetDate();
                        //enddate = usrPolicyComDate.GetDate().AddDays(365);

                        inputannualcomdate.Value = Request.Form["annualcomdate"].ToString().Trim();

                        string[] startdateformatted = Request.Form["annualcomdate"].ToString().Trim().Split('/');
                        string startdate1 = startdateformatted[2] + "-" + startdateformatted[1] + "-" + startdateformatted[0];

                        startdate = Convert.ToDateTime(startdate1);
                        enddate = Convert.ToDateTime(startdate1).AddDays(365);
                    }

                }
                else if (ddlPolicyType.Text == "FML")
                {

                    if (ddlTripType.SelectedValue == "S") //single trip
                    {
                        //Scenario 3          
                        countryid = Convert.ToInt64(ddlDestCountry.SelectedValue.ToString()); //Convert.ToInt64(ddlS3DestCountry.SelectedValue.ToString());

                        inputFrom.Value = Request.Form["from"].ToString().Trim();
                        string[] startdateformatted = Request.Form["from"].ToString().Trim().Split('/');
                        string startdate1 = startdateformatted[2] + "-" + startdateformatted[1] + "-" + startdateformatted[0];

                        inputTo.Value = Request.Form["to"].ToString().Trim();
                        string[] enddateformatted = Request.Form["to"].ToString().Trim().Split('/');
                        string enddate1 = enddateformatted[2] + "-" + enddateformatted[1] + "-" + enddateformatted[0];

                        DateTime dtStart = Convert.ToDateTime(startdate1);
                        DateTime dtEnd = Convert.ToDateTime(enddate1);

                        //duration = ComputeDuration(usrTravelStartDate.GetDate(), usrTravelEndDate.GetDate()); // ComputeDuration(usrS3TravelStartDate.GetDate(), usrS3TravelEndDate.GetDate());                        
                        duration = ComputeDuration(dtStart, dtEnd);

                        startdate = dtStart; // usrTravelStartDate.GetDate();
                        enddate = dtEnd; // usrTravelEndDate.GetDate();
                        adultage1 = ComputeAge(usrAdult1DOBSingle.GetDate());
                        adultage2 = ComputeAge(usrAdult2DOBSingle.GetDate());

                        childage = ComputeAge(usrChild1DOBSingle.GetDate());
                        noofadults = Convert.ToInt32(ddlNoOfAdultsSingle.SelectedValue.ToString());
                        noofchilds = Convert.ToInt32(ddlNoOfChildsSingle.SelectedValue.ToString());

                        for (int i = 1; i <= noofadults; i++)
                        {
                            if (i == 1)
                            {
                                dobadult1 = usrAdult1DOBSingle.GetDate();
                            }
                            if (i == 2)
                            {
                                dobadult2 = usrAdult2DOBSingle.GetDate();
                            }

                        }
                        for (int j = 1; j <= noofchilds; j++)
                        {
                            if (j == 1)
                            {
                                dobchild1 = usrChild1DOBSingle.GetDate();
                            }
                            if (j == 2)
                            {
                                dobchild2 = usrChild2DOBSingle.GetDate();
                            }
                            if (j == 3)
                            {
                                dobchild3 = usrChild3DOBSingle.GetDate();
                            }
                            if (j == 4)
                            {
                                dobchild4 = usrChild4DOBSingle.GetDate();
                            }

                        }
                    }
                    else //annual trip
                    {
                        //Scenario 4
                        areaid = Convert.ToInt64(ddlDestRegion.SelectedValue.ToString()); //Convert.ToInt64(ddlS4DestRegion.SelectedValue.ToString());

                        // startdate = usrPolicyComDate.GetDate(); // usrTravelStartDate.GetDate(); // usrS3TravelStartDate.GetDate();
                        //enddate = usrPolicyComDate.GetDate().AddDays(365);

                        inputannualcomdate.Value = Request.Form["annualcomdate"].ToString().Trim();

                        string[] startdateformatted = Request.Form["annualcomdate"].ToString().Trim().Split('/');
                        string startdate1 = startdateformatted[2] + "-" + startdateformatted[1] + "-" + startdateformatted[0];

                        startdate = Convert.ToDateTime(startdate1);
                        enddate = Convert.ToDateTime(startdate1).AddDays(365);

                        adultage1 = ComputeAge(usrAdult1DOB.GetDate()); // ComputeAge(usrS3Adult1DOB.GetDate());
                        adultage2 = ComputeAge(usrAdult2DOB.GetDate()); //ComputeAge(usrS3Adult2DOB.GetDate());

                        childage = ComputeAge(usrChild1DOB.GetDate()); //ComputeAge(usrS3Child1DOB.GetDate());
                        noofadults = Convert.ToInt32(ddlNoOfAdults.SelectedValue.ToString()); //Convert.ToInt32(ddlS3NoOfAdults.SelectedValue.ToString());
                        noofchilds = Convert.ToInt32(ddlNoOfChilds.SelectedValue.ToString());  //Convert.ToInt32(ddlS3NoOfChilds.SelectedValue.ToString());

                        for (int i = 1; i <= noofadults; i++)
                        {
                            if (i == 1)
                            {
                                dobadult1 = usrAdult1DOB.GetDate(); //usrS3Adult1DOB.GetDate();
                            }
                            if (i == 2)
                            {
                                dobadult2 = usrAdult2DOB.GetDate(); //usrS3Adult2DOB.GetDate();
                            }

                        }
                        for (int j = 1; j <= noofchilds; j++)
                        {
                            if (j == 1)
                            {
                                dobchild1 = usrChild1DOB.GetDate(); //usrS3Child1DOB.GetDate();
                            }
                            if (j == 2)
                            {
                                dobchild2 = usrChild2DOB.GetDate(); //usrS3Child2DOB.GetDate();
                            }
                            if (j == 3)
                            {
                                dobchild3 = usrChild3DOB.GetDate(); //usrS3Child3DOB.GetDate();
                            }
                            if (j == 4)
                            {
                                dobchild4 = usrChild4DOB.GetDate(); //usrS3Child4DOB.GetDate();
                            }
                            if (j == 5)
                            {
                                dobchild5 = usrChild5DOB.GetDate(); //usrS3Child5DOB.GetDate();
                            }
                            if (j == 6)
                            {
                                dobchild6 = usrChild6DOB.GetDate(); //usrS3Child6DOB.GetDate();
                            }
                        }
                    }

                }
                else if (ddlPolicyType.Text == "INS")
                {

                    adultage1 = ComputeAge(usrBirthday.GetDate()); ;
                    adultage2 = ComputeAge(usrBirthdaySpouse.GetDate());
                    dobadult1 = usrBirthday.GetDate();
                    dobadult2 = usrBirthdaySpouse.GetDate();
                    noofadults = 2;
                    noofchilds = 0;
                    
                    if (ddlTripType.SelectedValue == "S")
                    {
                        //Scenario 5

                        inputFrom.Value = Request.Form["from"].ToString().Trim();
                        string[] startdateformatted = Request.Form["from"].ToString().Trim().Split('/');
                        string startdate1 = startdateformatted[2] + "-" + startdateformatted[1] + "-" + startdateformatted[0];

                        inputTo.Value = Request.Form["to"].ToString().Trim();
                        string[] enddateformatted = Request.Form["to"].ToString().Trim().Split('/');
                        string enddate1 = enddateformatted[2] + "-" + enddateformatted[1] + "-" + enddateformatted[0];

                        DateTime dtStart = Convert.ToDateTime(startdate1);
                        DateTime dtEnd = Convert.ToDateTime(enddate1);

                        startdate = dtStart; // usrTravelStartDate.GetDate();
                        enddate = dtEnd; // usrTravelEndDate.GetDate();
                        countryid = Convert.ToInt64(ddlDestCountry.SelectedValue.ToString());
                        duration = ComputeDuration(dtStart, dtEnd);

                    }
                    else
                    {
                        //Scenario 6
                        areaid = Convert.ToInt64(ddlDestRegion.SelectedValue.ToString());
                        adultage1 = ComputeAge(usrBirthday.GetDate());
                        adultage2 = ComputeAge(usrBirthdaySpouse.GetDate());

                        //startdate = usrPolicyComDate.GetDate(); // usrTravelStartDate.GetDate(); // usrS3TravelStartDate.GetDate();
                        //enddate = usrPolicyComDate.GetDate().AddDays(365);

                        inputannualcomdate.Value = Request.Form["annualcomdate"].ToString().Trim();

                        string[] startdateformatted = Request.Form["annualcomdate"].ToString().Trim().Split('/');
                        string startdate1 = startdateformatted[2] + "-" + startdateformatted[1] + "-" + startdateformatted[0];

                        startdate = Convert.ToDateTime(startdate1);
                        enddate = Convert.ToDateTime(startdate1).AddDays(365);

                    }

                }



                string[] customerage = { adultage1.ToString(), adultage2.ToString(), adultage3.ToString(), adultage4.ToString() };
                Session[General.TACustomerAge] = customerage;


                #endregion

                TAApplicantSearch _taapplicantsearch = new TAApplicantSearch();
                TAApplicantSearchDB _taapplicantsearchdb = new TAApplicantSearchDB();

                if (Session[General.TAId] == null)
                {
                    _taapplicantsearch.TAAppSeaId = 0;
                }
                else
                {
                    _taapplicantsearch.TAAppSeaId = Convert.ToInt64(Session[General.TAId].ToString());
                }

                //Sakthi on 15 Feb 2011 -- Start
                //if (Session[General.UserId] == null)
                //{
                //    _taapplicantsearch.RefCEUserId = CheckAndCreateAndSendMailToUser();
                //}
                //else
                //{
                //    _taapplicantsearch.RefCEUserId = Convert.ToInt64(Session[General.UserId].ToString());
                //    SendMailToUser(_taapplicantsearch.RefCEUserId, true, Session[General.UserEmail].ToString(), Session[General.UserName].ToString(), "");
                //}

                //_taapplicantsearch.Name = ""; // txtOwnerName.Text.Trim();
                //_taapplicantsearch.EmailAddress = ""; // txtOwnerEmailAddress.Text.Trim();
                //_taapplicantsearch.MobileNum = ""; // txtOwnerPhoneNo.GetPhoneNo().ToString();

                if (Session[General.UserId] == null)
                {
                    _taapplicantsearch.RefCEUserId = 0;
                    _taapplicantsearch.Name = "";// txtFullName.Text.ToUpper();
                    _taapplicantsearch.EmailAddress = ""; // txtEmail.Text;
                    _taapplicantsearch.MobileNum = ""; // txtMobileNo.GetPhoneNo();
                }
                else
                {
                    _taapplicantsearch.RefCEUserId = Convert.ToInt64(Session[General.UserId].ToString());
                    _taapplicantsearch.Name = Session[General.UserName].ToString();
                    _taapplicantsearch.EmailAddress = Session[General.UserEmail].ToString();
                    _taapplicantsearch.MobileNum = Session[General.UserPhoneNo].ToString();
                }
                //Sakthi on 15 Feb 2011 -- End

                _taapplicantsearch.PlanType = ddlPolicyType.SelectedValue.ToString();
                _taapplicantsearch.TripType = ddlTripType.SelectedValue.ToString();
                _taapplicantsearch.CountryID = countryid;
                _taapplicantsearch.AreaID = areaid;
                _taapplicantsearch.CoverageLevel = coveragelevel;
                _taapplicantsearch.Duration = duration;
                _taapplicantsearch.StartDate = startdate;
                _taapplicantsearch.EndDate = enddate;
                _taapplicantsearch.ChildAge = childage;
                _taapplicantsearch.AdultAge = adultage1;
                _taapplicantsearch.NoOfTravellers = noofadults + noofchilds;//GetNoOfTravellers();
                _taapplicantsearch.TotalPremium = 0;

                _taapplicantsearch.NoofAdults = noofadults;
                _taapplicantsearch.DOBAdult1 = dobadult1;
                _taapplicantsearch.DOBAdult2 = dobadult2;
                _taapplicantsearch.DOBAdult3 = dobadult3;
                _taapplicantsearch.DOBAdult4 = dobadult4;
                _taapplicantsearch.NoofChilds = noofchilds;
                _taapplicantsearch.DOBChild1 = dobchild1;
                _taapplicantsearch.DOBChild2 = dobchild2;
                _taapplicantsearch.DOBChild3 = dobchild3;
                _taapplicantsearch.DOBChild4 = dobchild4;
                _taapplicantsearch.DOBChild5 = dobchild5;
                _taapplicantsearch.DOBChild6 = dobchild6;

                if (Session[General.ViewedDetailsId] == null)
                {
                    _taapplicantsearch.ViewedDetailId = 0;
                }
                else
                {
                    _taapplicantsearch.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
                }

                if (inputPID.Value.Trim() != "")
                {
                    Int64 iPID = Convert.ToInt64(inputPID.Value.Trim());
                    _taapplicantsearch.Ninfo3 = iPID;
                }
                else
                {
                    _taapplicantsearch.Ninfo3 = 0;
                }

                _taapplicantsearch.Info1 = "1";
                Int64 _result = _taapplicantsearchdb.Insert(_taapplicantsearch);

                if (_result > 0)
                {
                    Session["TripType"] = ddlTripType.Text;
                    Session["PlanType"] = _taapplicantsearch.PlanType;
                    Session[General.TAId] = _result.ToString();

                    if (Session[General.UserId] == null)
                    {
                        Session[General.TAPersonnelId] = _taapplicantsearch.RefCEUserId.ToString();
                        Session[General.TAUserName] = ""; // txtFullName.Text.ToUpper();
                        Session[General.TAPhoneNo] = ""; //txtMobileNo.GetPhoneNo().ToString();
                        Session[General.TAEmail] = ""; //txtEmail.Text;
                    }

                    Int64 TAAppSeaId = Convert.ToInt64(Session[General.TAId].ToString());
                    string Status = "2";
                    Int64 _updateresult = _taapplicantsearchdb.UpdateStatus(TAAppSeaId, Status);
                    if (_updateresult > 0)
                    {
                        //Response.Redirect("taresultsquotesone.aspx");

                        ResultsQuotesDataBind();

                        if (Request.QueryString["pid"] != null)
                        {
                            if (Request.QueryString["pid"].ToString() != "")
                            {
                                //Response.Redirect("results.aspx?pid=" + Request.QueryString["pid"].ToString());
                                Response.Redirect("results-details.aspx?pid=" + Request.QueryString["pid"].ToString());
                            }
                            else
                            {
                                Response.Redirect("results-details.aspx");
                            }
                        }
                        else
                        {
                            Response.Redirect("results-details.aspx");
                        }

                    }
                }

                LogUserViewedHistory();
            }
        }
    }

    private void CheckValidation()
    {

        usrBirthday.IsEnableValidation(false);
        usrBirthdaySpouse.IsEnableValidation(false);
        //usrTravelStartDate.IsEnableValidation(false);
        //usrTravelEndDate.IsEnableValidation(false);
        //usrPolicyComDate.IsEnableValidation(false);

        rfvCountry.Enabled = false;
        rfvDestCountry.Enabled = false;
        rfvDestRegion.Enabled = false;
        rfvNoOfAdults.Enabled = false;
        rfvNoOfChilds.Enabled = false;
        rfvNoOfAdultsSingle.Enabled = false;
        rfvNoOfChildsSingle.Enabled = false;

        usrAdult1DOB.IsEnableValidation(false);
        usrAdult2DOB.IsEnableValidation(false);
        usrAdult1DOBSingle.IsEnableValidation(false);
        usrAdult2DOBSingle.IsEnableValidation(false);

        usrChild1DOB.IsEnableValidation(false);
        usrChild2DOB.IsEnableValidation(false);
        usrChild3DOB.IsEnableValidation(false);
        usrChild4DOB.IsEnableValidation(false);
        usrChild5DOB.IsEnableValidation(false);
        usrChild6DOB.IsEnableValidation(false);

        usrChild1DOBSingle.IsEnableValidation(false);
        usrChild2DOBSingle.IsEnableValidation(false);
        usrChild3DOBSingle.IsEnableValidation(false);
        usrChild4DOBSingle.IsEnableValidation(false);

        if (ddlTripType.SelectedValue == "S") //(snum.Value == "1") 
        {
            //usrTravelEndDate.IsEnableValidation(true);
            //usrTravelStartDate.IsEnableValidation(true);
            rfvDestCountry.Enabled = true;
            rfvCountry.Enabled = true;

        }
        else if (ddlTripType.SelectedValue == "A") //(snum.Value == "2")        
        {
            //usrPolicyComDate.IsEnableValidation(true);
            rfvDestRegion.Enabled = true;

        }

        if (ddlPolicyType.SelectedValue == "IND") //(snum.Value == "3")
        {
            usrBirthday.IsEnableValidation(true);

        }
        else if (ddlPolicyType.SelectedValue == "FML") //(snum.Value == "4") 
        {
            rfvNoOfAdults.Enabled = true;
            rfvNoOfChilds.Enabled = true;

            if (ddlTripType.SelectedValue == "S")
            {
                if (ddlNoOfAdultsSingle.SelectedValue == "1")
                {
                    usrAdult1DOBSingle.IsEnableValidation(true);
                }

                if (ddlNoOfAdultsSingle.SelectedValue == "2")
                {
                    usrAdult1DOBSingle.IsEnableValidation(true);
                    usrAdult2DOBSingle.IsEnableValidation(true);
                }

                if (ddlNoOfChildsSingle.SelectedValue == "1")
                {
                    usrChild1DOBSingle.IsEnableValidation(true);
                }

                if (ddlNoOfChildsSingle.SelectedValue == "2")
                {
                    usrChild1DOBSingle.IsEnableValidation(true);
                    usrChild2DOBSingle.IsEnableValidation(true);
                }

                if (ddlNoOfChildsSingle.SelectedValue == "3")
                {
                    usrChild1DOBSingle.IsEnableValidation(true);
                    usrChild2DOBSingle.IsEnableValidation(true);
                    usrChild3DOBSingle.IsEnableValidation(true); ;
                }

                if (ddlNoOfChildsSingle.SelectedValue == "4")
                {
                    usrChild1DOBSingle.IsEnableValidation(true);
                    usrChild2DOBSingle.IsEnableValidation(true);
                    usrChild3DOBSingle.IsEnableValidation(true);
                    usrChild4DOBSingle.IsEnableValidation(true);
                }

            }
            else
            {

                if (ddlNoOfAdults.SelectedValue == "1")
                {
                    usrAdult1DOB.IsEnableValidation(true);

                }

                if (ddlNoOfAdults.SelectedValue == "2")
                {
                    usrAdult1DOB.IsEnableValidation(true);
                    usrAdult2DOB.IsEnableValidation(true);
                }


                if (ddlNoOfChilds.SelectedValue == "1")
                {
                    usrChild1DOB.IsEnableValidation(true);
                }

                if (ddlNoOfChilds.SelectedValue == "2")
                {
                    usrChild1DOB.IsEnableValidation(true);
                    usrChild2DOB.IsEnableValidation(true);
                }

                if (ddlNoOfChilds.SelectedValue == "3")
                {
                    usrChild1DOB.IsEnableValidation(true);
                    usrChild2DOB.IsEnableValidation(true);
                    usrChild3DOB.IsEnableValidation(true); ;
                }

                if (ddlNoOfChilds.SelectedValue == "4")
                {
                    usrChild1DOB.IsEnableValidation(true);
                    usrChild2DOB.IsEnableValidation(true);
                    usrChild3DOB.IsEnableValidation(true);
                    usrChild4DOB.IsEnableValidation(true);
                }


                if (ddlNoOfChilds.SelectedValue == "5")
                {
                    usrChild1DOB.IsEnableValidation(true);
                    usrChild2DOB.IsEnableValidation(true);
                    usrChild3DOB.IsEnableValidation(true);
                    usrChild4DOB.IsEnableValidation(true);
                    usrChild5DOB.IsEnableValidation(true);
                }

                if (ddlNoOfChilds.SelectedValue == "6")
                {
                    usrChild1DOB.IsEnableValidation(true);
                    usrChild2DOB.IsEnableValidation(true);
                    usrChild3DOB.IsEnableValidation(true);
                    usrChild4DOB.IsEnableValidation(true);
                    usrChild5DOB.IsEnableValidation(true);
                    usrChild6DOB.IsEnableValidation(true);
                }
            }
        }
        else if (ddlPolicyType.SelectedValue == "INS") //(snum.Value == "5") 
        {
            usrBirthday.IsEnableValidation(true);
            usrBirthdaySpouse.IsEnableValidation(true);

            //Response.Write("<script>window.alert('individ+spouse')</script>");
        }


        //if (divUserInfo.Visible == true)
        //{
        //    txtFullName.Text = General.ClearScriptTag(txtFullName.Text);
        //    txtFullName.Text = Server.HtmlEncode(txtFullName.Text);

        //    txtEmail.Text = General.ClearScriptTag(txtEmail.Text);
        //    txtEmail.Text = Server.HtmlEncode(txtEmail.Text);
        //}
    }

    private int GetNoOfTravellers()
    {
        int travellers = 0;

        if (ddlPolicyType.SelectedValue == "IND")
            travellers = 1;
        else if (ddlPolicyType.SelectedValue == "INS")
        {
            travellers = 2;
        }
        else
        {
            travellers = Convert.ToInt32(ddlNoOfAdults.Text) + Convert.ToInt32(ddlNoOfChilds.Text);
        }

        return travellers;
    }

    private int ComputeDuration(DateTime dtFrom, DateTime dtTo)
    {
        int TripDuration = 0;
        TripDuration = Convert.ToInt32(dtTo.Subtract(dtFrom).TotalDays.ToString());
        TripDuration = TripDuration + 1;

        return TripDuration;
    }

    private int ComputeAge(DateTime dtBirth)
    {
        int Age = 0;

        DateTime now = CE.Global.General.GetUTCDateTime();// DateTime.Today;
        Age = now.Year - dtBirth.Year;
        // subtract another year if we're before the birthday in the current year
        if (now.Month < dtBirth.Month || (now.Month == dtBirth.Month && now.Day < dtBirth.Day))
            --Age;

        return Age;
    }

    private string GetAreadIdOfCountry(Int64 CountryId)
    {
        string AreaId = "0";
        AreaCountryInfoDB _areacountrydb = new AreaCountryInfoDB();
        AreaId = _areacountrydb.GetAreaIDByCountryID(CountryId).ToString();

        return AreaId;
    }

    private void ClearSession()
    {
        Session[General.TAId] = null;
        Session[General.TAPhoneNo] = null;
        Session[General.TAEmail] = null;
        Session[General.TAUserName] = null;
        Session[General.TAResultId] = null;
        Session[General.TACustomerAge] = null;
    }

    private void ChangeControlSetting()
    {
        ddlTripType.Attributes.Add("onblur", "ShowValidationEffect('" + ddlTripType.ClientID + "','" + rfvTripType.ClientID + "');");
        ddlPolicyType.Attributes.Add("onblur", "ShowValidationEffect('" + ddlPolicyType.ClientID + "','" + rfvPolicyType.ClientID + "');");

        txtCountry.Attributes.Add("onblur", "ShowValidationEffect('" + txtCountry.ClientID + "','" + rfvCountry.ClientID + "');");
        ddlDestCountry.Attributes.Add("onblur", "ShowValidationEffect('" + ddlDestCountry.ClientID + "','" + rfvDestCountry.ClientID + "');");
        ddlDestRegion.Attributes.Add("onblur", "ShowValidationEffect('" + ddlDestRegion.ClientID + "','" + rfvDestRegion.ClientID + "');");
        ddlNoOfAdults.Attributes.Add("onblur", "ShowValidationEffect('" + ddlNoOfAdults.ClientID + "','" + rfvNoOfAdults.ClientID + "');");
        ddlNoOfChilds.Attributes.Add("onblur", "ShowValidationEffect('" + ddlNoOfChilds.ClientID + "','" + rfvNoOfChilds.ClientID + "');");
        ddlNoOfAdultsSingle.Attributes.Add("onblur", "ShowValidationEffect('" + ddlNoOfAdults.ClientID + "','" + rfvNoOfAdults.ClientID + "');");
        ddlNoOfChildsSingle.Attributes.Add("onblur", "ShowValidationEffect('" + ddlNoOfChilds.ClientID + "','" + rfvNoOfChilds.ClientID + "');");

        //Traveller's Info
        //txtOwnerName.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtOwnerName.ClientID + "','" + rfvOwnerName.ClientID + "','" + revOwnerName.ClientID + "');");
        //txtOwnerEmailAddress.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtOwnerEmailAddress.ClientID + "','" + rfvOwnerEmailAddress.ClientID + "','" + revOwnerEmailAddress.ClientID + "');");
    }

    private void ShowUserDetails()
    {
        //hplEditProfile.Visible = true;

        CE.User.Profile _profile = new CE.User.Profile();
        CE.User.ProfileDB _profiledb = new ProfileDB();
        CE.User.Contact _contact = new Contact();
        CE.User.ContactDB _contactdb = new ContactDB();

        Int64 UserId = Convert.ToInt64(Session[General.UserId].ToString());
        _profile = _profiledb.GetProfile(UserId);
        if (_profile != null)
        {

            //if (_profile.FirstName != null && _profile.FirstName.Trim() != string.Empty)
            //{
            //    txtOwnerName.Text = _profile.SurName + " " + _profile.FirstName;
            //}
            //else
            //{
            //    txtOwnerName.Text = _profile.SurName;
            //}

            //_contact = _contactdb.GetContact(UserId);
            //if (_contact != null)
            //{
            //    txtOwnerPhoneNo.PhoneNo = _contact.Mobile;
            //    txtOwnerEmailAddress.Text = _contact.Email;

            //}
            //txtOwnerName.ReadOnly = true;
            //txtOwnerPhoneNo.IsReadOnly = true;
            //txtOwnerEmailAddress.ReadOnly = true;

            _profile = null;
            _profiledb = null;
            _contact = null;
            _contactdb = null;

            //txtOwnerName.Text = Session[CE.Global.General.UserName].ToString();
            //txtOwnerPhoneNo.PhoneNo = Session[CE.Global.General.UserPhoneNo].ToString();
            //txtOwnerEmailAddress.Text = Session[CE.Global.General.UserEmail].ToString();

            //txtOwnerName.ReadOnly = true;
            //txtOwnerPhoneNo.IsReadOnly = true;
            //txtOwnerEmailAddress.ReadOnly = true;
        }
    }

    private void ShowTADetails(Int64 TAId)
    {
        TAApplicantSearchDB _taapplicantsearchdb = new TAApplicantSearchDB();
        TAApplicantSearch _taapplicantsearch = new TAApplicantSearch();

        _taapplicantsearch = _taapplicantsearchdb.GetTAApplicantSearchItem(TAId);

        if (_taapplicantsearch != null)
        {

            //txtFullName.Text = _taapplicantsearch.Name;
            //txtEmail.Text = _taapplicantsearch.EmailAddress;
            //txtMobileNo.PhoneNo = _taapplicantsearch.MobileNum;

            ddlTripType.SelectedValue = _taapplicantsearch.TripType;
            ddlPolicyType.SelectedValue = _taapplicantsearch.PlanType;
            ddlCoverage.SelectedValue = _taapplicantsearch.CoverageLevel;

            //ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript: ChangeScenario(); ", true);

            if (_taapplicantsearch.TripType == "S")
            {
                ddlDestCountry.SelectedValue = _taapplicantsearch.CountryID.ToString();
                txtCountry.Text = ddlDestCountry.SelectedItem.Text;
                inputSelCountryName.Value = ddlDestCountry.SelectedItem.Text;
                //usrTravelStartDate.Day = _taapplicantsearch.StartddlDestCountry.SelectedItem.Text;Date.Day;
                //usrTravelStartDate.Month = _taapplicantsearch.StartDate.Month;
                //usrTravelStartDate.Year = _taapplicantsearch.StartDate.Year;
                //usrTravelEndDate.Day = _taapplicantsearch.EndDate.Day;
                //usrTravelEndDate.Month = _taapplicantsearch.EndDate.Month;
                //usrTravelEndDate.Year = _taapplicantsearch.EndDate.Year;

                inputFrom.Value = _taapplicantsearch.StartDate.ToString("dd/MM/yyyy");
                inputTo.Value = _taapplicantsearch.EndDate.ToString("dd/MM/yyyy");


            }
            else if (_taapplicantsearch.TripType == "A")
            {
                ddlDestRegion.SelectedValue = _taapplicantsearch.AreaID.ToString();
                //usrPolicyComDate.Day = _taapplicantsearch.StartDate.Day;
                //usrPolicyComDate.Month = _taapplicantsearch.StartDate.Month;
                //usrPolicyComDate.Year = _taapplicantsearch.StartDate.Year;

                inputannualcomdate.Value = _taapplicantsearch.StartDate.ToString("dd/MM/yyyy");

            }

            if (_taapplicantsearch.PlanType == "IND")
            {
                if (_taapplicantsearch.DOBAdult1 != null)
                {
                    usrBirthday.Day = _taapplicantsearch.DOBAdult1.Day;
                    usrBirthday.Month = _taapplicantsearch.DOBAdult1.Month;
                    usrBirthday.Year = _taapplicantsearch.DOBAdult1.Year;
                }
            }
            else if (_taapplicantsearch.PlanType == "FML")
            {


                if (_taapplicantsearch.TripType == "S")
                {
                    ddlNoOfAdultsSingle.Text = _taapplicantsearch.NoofAdults.ToString();
                    ddlNoOfChildsSingle.Text = _taapplicantsearch.NoofChilds.ToString();

                    usrAdult1DOBSingle.Day = _taapplicantsearch.DOBAdult1.Day;
                    usrAdult1DOBSingle.Month = _taapplicantsearch.DOBAdult1.Month;
                    usrAdult1DOBSingle.Year = _taapplicantsearch.DOBAdult1.Year;

                    if (_taapplicantsearch.NoofAdults > 1) //no of adults
                    {
                        usrAdult2DOBSingle.Day = _taapplicantsearch.DOBAdult2.Day;
                        usrAdult2DOBSingle.Month = _taapplicantsearch.DOBAdult2.Month;
                        usrAdult2DOBSingle.Year = _taapplicantsearch.DOBAdult2.Year;
                    }

                    usrChild1DOBSingle.Day = _taapplicantsearch.DOBChild1.Day;
                    usrChild1DOBSingle.Month = _taapplicantsearch.DOBChild1.Month;
                    usrChild1DOBSingle.Year = _taapplicantsearch.DOBChild1.Year;

                    if (_taapplicantsearch.NoofChilds > 1) //no of child
                    {
                        usrChild2DOBSingle.Day = _taapplicantsearch.DOBChild2.Day;
                        usrChild2DOBSingle.Month = _taapplicantsearch.DOBChild2.Month;
                        usrChild2DOBSingle.Year = _taapplicantsearch.DOBChild2.Year;
                    }
                    if (_taapplicantsearch.NoofChilds > 2)
                    {
                        usrChild3DOBSingle.Day = _taapplicantsearch.DOBChild3.Day;
                        usrChild3DOBSingle.Month = _taapplicantsearch.DOBChild3.Month;
                        usrChild3DOBSingle.Year = _taapplicantsearch.DOBChild3.Year;
                    }
                    if (_taapplicantsearch.NoofChilds > 3)
                    {
                        usrChild4DOBSingle.Day = _taapplicantsearch.DOBChild4.Day;
                        usrChild4DOBSingle.Month = _taapplicantsearch.DOBChild4.Month;
                        usrChild4DOBSingle.Year = _taapplicantsearch.DOBChild4.Year;
                    }

                }
                else
                {
                    ddlNoOfAdults.Text = _taapplicantsearch.NoofAdults.ToString();
                    ddlNoOfChilds.Text = _taapplicantsearch.NoofChilds.ToString();

                    usrAdult1DOB.Day = _taapplicantsearch.DOBAdult1.Day;
                    usrAdult1DOB.Month = _taapplicantsearch.DOBAdult1.Month;
                    usrAdult1DOB.Year = _taapplicantsearch.DOBAdult1.Year;

                    if (_taapplicantsearch.NoofAdults > 1) //no of adults
                    {
                        usrAdult2DOB.Day = _taapplicantsearch.DOBAdult2.Day;
                        usrAdult2DOB.Month = _taapplicantsearch.DOBAdult2.Month;
                        usrAdult2DOB.Year = _taapplicantsearch.DOBAdult2.Year;
                    }

                    usrChild1DOB.Day = _taapplicantsearch.DOBChild1.Day;
                    usrChild1DOB.Month = _taapplicantsearch.DOBChild1.Month;
                    usrChild1DOB.Year = _taapplicantsearch.DOBChild1.Year;

                    if (_taapplicantsearch.NoofChilds > 1) //no of child
                    {
                        usrChild2DOB.Day = _taapplicantsearch.DOBChild2.Day;
                        usrChild2DOB.Month = _taapplicantsearch.DOBChild2.Month;
                        usrChild2DOB.Year = _taapplicantsearch.DOBChild2.Year;
                    }
                    if (_taapplicantsearch.NoofChilds > 2)
                    {
                        usrChild3DOB.Day = _taapplicantsearch.DOBChild3.Day;
                        usrChild3DOB.Month = _taapplicantsearch.DOBChild3.Month;
                        usrChild3DOB.Year = _taapplicantsearch.DOBChild3.Year;
                    }
                    if (_taapplicantsearch.NoofChilds > 3)
                    {
                        usrChild4DOB.Day = _taapplicantsearch.DOBChild4.Day;
                        usrChild4DOB.Month = _taapplicantsearch.DOBChild4.Month;
                        usrChild4DOB.Year = _taapplicantsearch.DOBChild4.Year;
                    }
                    if (_taapplicantsearch.NoofChilds > 4)
                    {
                        usrChild5DOB.Day = _taapplicantsearch.DOBChild5.Day;
                        usrChild5DOB.Month = _taapplicantsearch.DOBChild5.Month;
                        usrChild5DOB.Year = _taapplicantsearch.DOBChild5.Year;
                    }
                    if (_taapplicantsearch.NoofChilds > 5)
                    {
                        usrChild6DOB.Day = _taapplicantsearch.DOBChild6.Day;
                        usrChild6DOB.Month = _taapplicantsearch.DOBChild6.Month;
                        usrChild6DOB.Year = _taapplicantsearch.DOBChild6.Year;
                    }
                }
            }
            else if (_taapplicantsearch.PlanType == "INS")
            {
                if (_taapplicantsearch.DOBAdult1 != null)
                {
                    usrBirthday.Day = _taapplicantsearch.DOBAdult1.Day;
                    usrBirthday.Month = _taapplicantsearch.DOBAdult1.Month;
                    usrBirthday.Year = _taapplicantsearch.DOBAdult1.Year;
                }

                if (_taapplicantsearch.DOBAdult2 != null)
                {
                    usrBirthdaySpouse.Day = _taapplicantsearch.DOBAdult2.Day;
                    usrBirthdaySpouse.Month = _taapplicantsearch.DOBAdult2.Month;
                    usrBirthdaySpouse.Year = _taapplicantsearch.DOBAdult2.Year;
                }
            }




        }
    }

    private void ChangeDateSetting()
    {

        //usrTravelStartDate.IsTravelInsurance = true;
        //usrTravelStartDate.StartYear = CE.Global.General.GetUTCDateTime().Year;
        //usrTravelStartDate.EndYear = CE.Global.General.GetUTCDateTime().Year + 1;

        //usrTravelEndDate.IsTravelInsurance = true;
        //usrTravelEndDate.StartYear = CE.Global.General.GetUTCDateTime().Year;
        //usrTravelEndDate.EndYear = CE.Global.General.GetUTCDateTime().Year + 1;

        //usrPolicyComDate.IsNotLessThanToday = true;
        //usrPolicyComDate.StartYear = CE.Global.General.GetUTCDateTime().Year;
        //usrPolicyComDate.EndYear = CE.Global.General.GetUTCDateTime().Year + 2;

        usrAdult1DOB.StartYear = CE.Global.General.GetUTCDateTime().Year - 100;
        usrAdult1DOB.EndYear = CE.Global.General.GetUTCDateTime().Year - 18;

        usrAdult2DOB.StartYear = CE.Global.General.GetUTCDateTime().Year - 100;
        usrAdult2DOB.EndYear = CE.Global.General.GetUTCDateTime().Year - 18;

        usrAdult1DOBSingle.StartYear = CE.Global.General.GetUTCDateTime().Year - 100;
        usrAdult1DOBSingle.EndYear = CE.Global.General.GetUTCDateTime().Year - 18;

        usrAdult2DOBSingle.StartYear = CE.Global.General.GetUTCDateTime().Year - 100;
        usrAdult2DOBSingle.EndYear = CE.Global.General.GetUTCDateTime().Year - 18;

        usrChild1DOB.IsAllowGreaterThanToday = false;
        usrChild1DOB.StartYear = CE.Global.General.GetUTCDateTime().Year - 23;
        usrChild1DOB.EndYear = CE.Global.General.GetUTCDateTime().Year;

        usrChild2DOB.IsAllowGreaterThanToday = false;
        usrChild2DOB.StartYear = CE.Global.General.GetUTCDateTime().Year - 23;
        usrChild2DOB.EndYear = CE.Global.General.GetUTCDateTime().Year;

        usrChild3DOB.IsAllowGreaterThanToday = false;
        usrChild3DOB.StartYear = CE.Global.General.GetUTCDateTime().Year - 23;
        usrChild3DOB.EndYear = CE.Global.General.GetUTCDateTime().Year;

        usrChild4DOB.IsAllowGreaterThanToday = false;
        usrChild4DOB.StartYear = CE.Global.General.GetUTCDateTime().Year - 23;
        usrChild4DOB.EndYear = CE.Global.General.GetUTCDateTime().Year;

        usrChild5DOB.IsAllowGreaterThanToday = false;
        usrChild5DOB.StartYear = CE.Global.General.GetUTCDateTime().Year - 23;
        usrChild5DOB.EndYear = CE.Global.General.GetUTCDateTime().Year;

        usrChild6DOB.IsAllowGreaterThanToday = false;
        usrChild6DOB.StartYear = CE.Global.General.GetUTCDateTime().Year - 23;
        usrChild6DOB.EndYear = CE.Global.General.GetUTCDateTime().Year;

        usrChild1DOBSingle.IsAllowGreaterThanToday = false;
        usrChild1DOBSingle.StartYear = CE.Global.General.GetUTCDateTime().Year - 23;
        usrChild1DOBSingle.EndYear = CE.Global.General.GetUTCDateTime().Year;

        usrChild2DOBSingle.IsAllowGreaterThanToday = false;
        usrChild2DOBSingle.StartYear = CE.Global.General.GetUTCDateTime().Year - 23;
        usrChild2DOBSingle.EndYear = CE.Global.General.GetUTCDateTime().Year;

        usrChild3DOBSingle.IsAllowGreaterThanToday = false;
        usrChild3DOBSingle.StartYear = CE.Global.General.GetUTCDateTime().Year - 23;
        usrChild3DOBSingle.EndYear = CE.Global.General.GetUTCDateTime().Year;

        usrChild4DOBSingle.IsAllowGreaterThanToday = false;
        usrChild4DOBSingle.StartYear = CE.Global.General.GetUTCDateTime().Year - 23;
        usrChild4DOBSingle.EndYear = CE.Global.General.GetUTCDateTime().Year;

        usrBirthday.StartYear = CE.Global.General.GetUTCDateTime().Year - 100;
        usrBirthday.EndYear = CE.Global.General.GetUTCDateTime().Year - 18;

        usrBirthdaySpouse.StartYear = CE.Global.General.GetUTCDateTime().Year - 100;
        usrBirthdaySpouse.EndYear = CE.Global.General.GetUTCDateTime().Year - 18;

        DateTime _TravelDate = CE.Global.General.GetUTCDateTime().AddDays(+1);

        if (Request.UrlReferrer != null)
        {
            if (Request.UrlReferrer.AbsolutePath.ToString().ToLower() != "/travel-flights/results.aspx")
            {
                //usrTravelStartDate.Day = _TravelDate.Day;
                //usrTravelStartDate.Month = _TravelDate.Month;
                //usrTravelStartDate.Year = _TravelDate.Year;
                //usrTravelEndDate.Day = _TravelDate.Day;
                //usrTravelEndDate.Month = _TravelDate.Month;
                //usrTravelEndDate.Year = _TravelDate.Year;

                inputFrom.Value = _TravelDate.ToString("dd/MM/yyyy");
                inputTo.Value = _TravelDate.ToString("dd/MM/yyyy");

                inputannualcomdate.Value = _TravelDate.ToString("dd/MM/yyyy");

            }
        }
        else
        {
            //usrTravelStartDate.Day = _TravelDate.Day;
            //usrTravelStartDate.Month = _TravelDate.Month;
            //usrTravelStartDate.Year = _TravelDate.Year;
            //usrTravelEndDate.Day = _TravelDate.Day;
            //usrTravelEndDate.Month = _TravelDate.Month;
            //usrTravelEndDate.Year = _TravelDate.Year;

            inputFrom.Value = _TravelDate.ToString("dd/MM/yyyy");
            inputTo.Value = _TravelDate.ToString("dd/MM/yyyy");

            inputannualcomdate.Value = _TravelDate.ToString("dd/MM/yyyy");
        }

    }

    #region oldcode

    //protected void ChangeScenario2(object sender, EventArgs e)
    //{
    //    divS1.Visible = false;
    //    divS2.Visible = false;
    //    divS3.Visible = false;
    //    divS4.Visible = false;
    //    divS5.Visible = false;
    //    divS6.Visible = false;
    //    divS7.Visible = false;
    //    divS8.Visible = false;
    //    divUserInfo.Visible = false;
    //    DateTime _TravelDate =  CE.Global.General.GetUTCDateTime().AddDays(+1);

    //    if (ddlTripType.Text != "-1" && ddlPolicyType.Text != "-1")
    //    {
    //        if (Session[General.UserId] == null)
    //        {
    //            divUserInfo.Visible = true;
    //            //txtEmail.Attributes.Add("onfocus", "JT_ShowTwo('/tooltips/username.htm?width=250', '" + txtEmail.ClientID + "', 'CompareXpress User Account'); return true;");
    //            txtEmail.Attributes.Add("onblur", "$('#JT').remove();ShowValidationEffectTwo('" + txtEmail.ClientID + "','" + rfvEmail.ClientID + "','" + cxvEmail.ClientID + "')");
    //            txtFullName.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtFullName.ClientID + "','" + rfvFullName.ClientID + "','" + revFullName.ClientID + "')");
    //        }
    //    }
    //    if (ddlTripType.SelectedValue == "S" && ddlPolicyType.SelectedValue == "IND")
    //    {
    //        divS1.Visible = true;

    //        //usrS1TravelStartDate.Day = CE.Global.General.GetUTCDateTime().Day + 1;
    //        //usrS1TravelStartDate.Month = CE.Global.General.GetUTCDateTime().Month;
    //        //usrS1TravelStartDate.Year = CE.Global.General.GetUTCDateTime().Year;
    //        //usrS1TravelEndDate.Day = CE.Global.General.GetUTCDateTime().Day + 1;
    //        //usrS1TravelEndDate.Month = CE.Global.General.GetUTCDateTime().Month;
    //        //usrS1TravelEndDate.Year = CE.Global.General.GetUTCDateTime().Year;

    //        if (Request.UrlReferrer != null)
    //        {
    //            if (Request.UrlReferrer.AbsolutePath.ToString() != "/travel-flights/results.aspx")
    //            {
    //                usrS1TravelStartDate.Day = _TravelDate.Day;
    //                usrS1TravelStartDate.Month = _TravelDate.Month;
    //                usrS1TravelStartDate.Year = _TravelDate.Year;
    //                usrS1TravelEndDate.Day = _TravelDate.Day;
    //                usrS1TravelEndDate.Month = _TravelDate.Month;
    //                usrS1TravelEndDate.Year = _TravelDate.Year;
    //            }
    //        }
    //        else
    //        {
    //            usrS1TravelStartDate.Day = _TravelDate.Day;
    //            usrS1TravelStartDate.Month = _TravelDate.Month;
    //            usrS1TravelStartDate.Year = _TravelDate.Year;
    //            usrS1TravelEndDate.Day = _TravelDate.Day;
    //            usrS1TravelEndDate.Month = _TravelDate.Month;
    //            usrS1TravelEndDate.Year = _TravelDate.Year;
    //        }
    //    }
    //    else if (ddlTripType.SelectedValue == "A" && ddlPolicyType.SelectedValue == "IND")
    //    {
    //        divS2.Visible = true;
    //    }
    //    else if (ddlTripType.SelectedValue == "S" && ddlPolicyType.SelectedValue == "FML")
    //    {
    //        divS3.Visible = true;

    //        ddlS3NoOfAdults.SelectedIndex = 0;
    //        ddlS3NoOfChilds.SelectedIndex = 0;

    //        this.ChangeS3AdultScenario(this, null);
    //        this.ChangeS3ChildScenario(this, null);

    //        //usrS3TravelStartDate.Day = CE.Global.General.GetUTCDateTime().Day + 1;
    //        //usrS3TravelStartDate.Month = CE.Global.General.GetUTCDateTime().Month;
    //        //usrS3TravelStartDate.Year = CE.Global.General.GetUTCDateTime().Year;
    //        //usrS3TravelEndDate.Day = CE.Global.General.GetUTCDateTime().Day + 1;
    //        //usrS3TravelEndDate.Month = CE.Global.General.GetUTCDateTime().Month;
    //        //usrS3TravelEndDate.Year = CE.Global.General.GetUTCDateTime().Year;
    //        usrS3TravelStartDate.Day = _TravelDate.Day;
    //        usrS3TravelStartDate.Month = _TravelDate.Month;
    //        usrS3TravelStartDate.Year = _TravelDate.Year;
    //        usrS3TravelEndDate.Day = _TravelDate.Day;
    //        usrS3TravelEndDate.Month = _TravelDate.Month;
    //        usrS3TravelEndDate.Year = _TravelDate.Year;

    //    }
    //    else if (ddlTripType.SelectedValue == "A" && ddlPolicyType.SelectedValue == "FML")
    //    {
    //        divS4.Visible = true;

    //        ddlS4NoOfAdults.SelectedIndex = 0;
    //        ddlS4NoOfChilds.SelectedIndex = 0;

    //        this.ChangeS4AdultScenario(this, null);
    //        this.ChangeS4ChildScenario(this, null);
    //    }
    //    else if (ddlTripType.SelectedValue == "S" && ddlPolicyType.SelectedValue == "INS")
    //    {
    //        divS5.Visible = true;

    //        //usrS5TravelStartDate.Day = CE.Global.General.GetUTCDateTime().Day + 1;
    //        //usrS5TravelStartDate.Month = CE.Global.General.GetUTCDateTime().Month;
    //        //usrS5TravelStartDate.Year = CE.Global.General.GetUTCDateTime().Year;
    //        //usrS5TravelEndDate.Day = CE.Global.General.GetUTCDateTime().Day + 1;
    //        //usrS5TravelEndDate.Month = CE.Global.General.GetUTCDateTime().Month;
    //        //usrS5TravelEndDate.Year = CE.Global.General.GetUTCDateTime().Year;
    //        usrS5TravelStartDate.Day = _TravelDate.Day;
    //        usrS5TravelStartDate.Month = _TravelDate.Month;
    //        usrS5TravelStartDate.Year = _TravelDate.Year;
    //        usrS5TravelEndDate.Day = _TravelDate.Day;
    //        usrS5TravelEndDate.Month = _TravelDate.Month;
    //        usrS5TravelEndDate.Year = _TravelDate.Year;
    //    }
    //    else if (ddlTripType.SelectedValue == "A" && ddlPolicyType.SelectedValue == "INS")
    //    {
    //        divS6.Visible = true;
    //    }
    //    else if (ddlTripType.SelectedValue == "S" && ddlPolicyType.SelectedValue == "INC")
    //    {
    //        divS7.Visible = true;

    //        ddlS7NoOfChilds.SelectedIndex = 0;

    //        this.ChangeS7ChildScenario(this, null);

    //        //usrS7TravelStartDate.Day = CE.Global.General.GetUTCDateTime().Day + 1;
    //        //usrS7TravelStartDate.Month = CE.Global.General.GetUTCDateTime().Month;
    //        //usrS7TravelStartDate.Year = CE.Global.General.GetUTCDateTime().Year;
    //        //usrS7TravelEndDate.Day = CE.Global.General.GetUTCDateTime().Day + 1;
    //        //usrS7TravelEndDate.Month = CE.Global.General.GetUTCDateTime().Month;
    //        //usrS7TravelEndDate.Year = CE.Global.General.GetUTCDateTime().Year;
    //        usrS7TravelStartDate.Day = _TravelDate.Day;
    //        usrS7TravelStartDate.Month = _TravelDate.Month;
    //        usrS7TravelStartDate.Year = _TravelDate.Year;
    //        usrS7TravelEndDate.Day = _TravelDate.Day;
    //        usrS7TravelEndDate.Month = _TravelDate.Month;
    //        usrS7TravelEndDate.Year = _TravelDate.Year;
    //    }
    //    else if (ddlTripType.SelectedValue == "A" && ddlPolicyType.SelectedValue == "INC")
    //    {
    //        divS8.Visible = true;

    //        ddlS8NoOfChilds.SelectedIndex = 0;

    //        this.ChangeS8ChildScenario(this, null);
    //    }
    //    //ChangeDateSetting();
    //    CheckValidation();

    //    //ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Init_JTIP", "JT_init();", true);

    //}

    //protected void ChangeS3AdultScenario(object sender, EventArgs e)
    //{
    //    divS3Adult1.Visible = false;
    //    divS3Adult2.Visible = false;
    //    divS3Adult3.Visible = false;
    //    divS3Adult4.Visible = false;

    //    if (ddlS3NoOfAdults.SelectedIndex > 0)
    //    {
    //        int noOfAdults = int.Parse(ddlS3NoOfAdults.SelectedValue);

    //        for (int i = 1; i <= noOfAdults; i++)
    //        {
    //            if (i == 1)
    //            {
    //                divS3Adult1.Visible = true;
    //            }
    //            if (i == 2)
    //            {
    //                divS3Adult2.Visible = true;
    //            }
    //            if (i == 3)
    //            {
    //                divS3Adult3.Visible = true;
    //            }
    //            if (i == 4)
    //            {
    //                divS3Adult4.Visible = true;
    //            }
    //        }

    //    }

    //    //ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Init_JTIP", "JT_init();", true);

    //}

    //protected void ChangeS3ChildScenario(object sender, EventArgs e)
    //{
    //    divS3Child1.Visible = false;
    //    divS3Child2.Visible = false;
    //    divS3Child3.Visible = false;
    //    divS3Child4.Visible = false;
    //    divS3Child5.Visible = false;
    //    divS3Child6.Visible = false;


    //    if (ddlS3NoOfChilds.SelectedIndex > 0)
    //    {
    //        int noOfChild = int.Parse(ddlS3NoOfChilds.SelectedValue);

    //        for (int i = 1; i <= noOfChild; i++)
    //        {
    //            if (i == 1)
    //            {
    //                divS3Child1.Visible = true;
    //            }
    //            if (i == 2)
    //            {
    //                divS3Child2.Visible = true;
    //            }
    //            if (i == 3)
    //            {
    //                divS3Child3.Visible = true;
    //            }
    //            if (i == 4)
    //            {
    //                divS3Child4.Visible = true;
    //            }
    //            if (i == 5)
    //            {
    //                divS3Child5.Visible = true;
    //            }
    //            if (i == 6)
    //            {
    //                divS3Child6.Visible = true;
    //            }
    //        }
    //    }

    //    //ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Init_JTIP", "JT_init();", true);

    //}

    //protected void ChangeS4AdultScenario(object sender, EventArgs e)
    //{
    //    divS4Adult1.Visible = false;
    //    divS4Adult2.Visible = false;
    //    divS4Adult3.Visible = false;
    //    divS4Adult4.Visible = false;

    //    usrS4Adult1DOB.IsEnableValidation(false);
    //    usrS4Adult2DOB.IsEnableValidation(false);
    //    usrS4Adult3DOB.IsEnableValidation(false);
    //    usrS4Adult4DOB.IsEnableValidation(false);


    //    if (ddlS4NoOfAdults.SelectedIndex > 0)
    //    {
    //        int noOfAdults = int.Parse(ddlS4NoOfAdults.SelectedValue);

    //        for (int i = 1; i <= noOfAdults; i++)
    //        {
    //            if (i == 1)
    //            {
    //                divS4Adult1.Visible = true;
    //                usrS4Adult1DOB.IsEnableValidation(true);
    //            }
    //            if (i == 2)
    //            {
    //                divS4Adult2.Visible = true;
    //                usrS4Adult2DOB.IsEnableValidation(true);
    //            }
    //            if (i == 3)
    //            {
    //                divS4Adult3.Visible = true;
    //                usrS4Adult3DOB.IsEnableValidation(true);
    //            }
    //            if (i == 4)
    //            {
    //                divS4Adult4.Visible = true;
    //                usrS4Adult4DOB.IsEnableValidation(true);
    //            }
    //        }

    //    }

    //    //ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Init_JTIP", "JT_init();", true);

    //}

    //protected void ChangeS4ChildScenario(object sender, EventArgs e)
    //{
    //    divS4Child1.Visible = false;
    //    divS4Child2.Visible = false;
    //    divS4Child3.Visible = false;
    //    divS4Child4.Visible = false;
    //    divS4Child5.Visible = false;
    //    divS4Child6.Visible = false;

    //    usrS4Child1DOB.IsEnableValidation(false);
    //    usrS4Child2DOB.IsEnableValidation(false);
    //    usrS4Child3DOB.IsEnableValidation(false);
    //    usrS4Child4DOB.IsEnableValidation(false);
    //    usrS4Child5DOB.IsEnableValidation(false);
    //    usrS4Child6DOB.IsEnableValidation(false);


    //    if (ddlS4NoOfChilds.SelectedIndex > 0)
    //    {
    //        int noOfChild = int.Parse(ddlS4NoOfChilds.SelectedValue);

    //        for (int i = 1; i <= noOfChild; i++)
    //        {
    //            if (i == 1)
    //            {
    //                divS4Child1.Visible = true;
    //                usrS4Child1DOB.IsEnableValidation(true);
    //            }
    //            if (i == 2)
    //            {
    //                divS4Child2.Visible = true;
    //                usrS4Child2DOB.IsEnableValidation(true);
    //            }
    //            if (i == 3)
    //            {
    //                divS4Child3.Visible = true;
    //                usrS4Child3DOB.IsEnableValidation(true);
    //            }
    //            if (i == 4)
    //            {
    //                divS4Child4.Visible = true;
    //                usrS4Child4DOB.IsEnableValidation(true);
    //            }
    //            if (i == 5)
    //            {
    //                divS4Child5.Visible = true;
    //                usrS4Child5DOB.IsEnableValidation(true);
    //            }
    //            if (i == 6)
    //            {
    //                divS4Child6.Visible = true;
    //                usrS4Child6DOB.IsEnableValidation(true);
    //            }
    //        }
    //    }

    //    //ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Init_JTIP", "JT_init();", true);

    //}

    //protected void ChangeS7ChildScenario(object sender, EventArgs e)
    //{
    //    divS7Child1.Visible = false;
    //    divS7Child2.Visible = false;
    //    divS7Child3.Visible = false;
    //    divS7Child4.Visible = false;
    //    divS7Child5.Visible = false;
    //    divS7Child6.Visible = false;

    //    usrS7Child1DOB.IsEnableValidation(false);
    //    usrS7Child2DOB.IsEnableValidation(false);
    //    usrS7Child3DOB.IsEnableValidation(false);
    //    usrS7Child4DOB.IsEnableValidation(false);
    //    usrS7Child5DOB.IsEnableValidation(false);
    //    usrS7Child6DOB.IsEnableValidation(false);


    //    if (ddlS7NoOfChilds.SelectedIndex > 0)
    //    {
    //        int noOfChild = int.Parse(ddlS7NoOfChilds.SelectedValue);

    //        for (int i = 1; i <= noOfChild; i++)
    //        {
    //            if (i == 1)
    //            {
    //                divS7Child1.Visible = true;
    //                usrS7Child1DOB.IsEnableValidation(true);
    //            }
    //            if (i == 2)
    //            {
    //                divS7Child2.Visible = true;
    //                usrS7Child2DOB.IsEnableValidation(true);
    //            }
    //            if (i == 3)
    //            {
    //                divS7Child3.Visible = true;
    //                usrS7Child3DOB.IsEnableValidation(true);
    //            }
    //            if (i == 4)
    //            {
    //                divS7Child4.Visible = true;
    //                usrS7Child4DOB.IsEnableValidation(true);
    //            }
    //            if (i == 5)
    //            {
    //                divS7Child5.Visible = true;
    //                usrS7Child5DOB.IsEnableValidation(true);
    //            }
    //            if (i == 6)
    //            {
    //                divS7Child6.Visible = true;
    //                usrS7Child6DOB.IsEnableValidation(true);
    //            }
    //        }
    //    }

    //    //ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Init_JTIP", "JT_init();", true);
    //}

    //protected void ChangeS8ChildScenario(object sender, EventArgs e)
    //{
    //    divS8Child1.Visible = false;
    //    divS8Child2.Visible = false;
    //    divS8Child3.Visible = false;
    //    divS8Child4.Visible = false;
    //    divS8Child5.Visible = false;
    //    divS8Child6.Visible = false;

    //    usrS8Child1DOB.IsEnableValidation(false);
    //    usrS8Child2DOB.IsEnableValidation(false);
    //    usrS8Child3DOB.IsEnableValidation(false);
    //    usrS8Child4DOB.IsEnableValidation(false);
    //    usrS8Child5DOB.IsEnableValidation(false);
    //    usrS8Child6DOB.IsEnableValidation(false);


    //    if (ddlS8NoOfChilds.SelectedIndex > 0)
    //    {
    //        int noOfChild = int.Parse(ddlS8NoOfChilds.SelectedValue);

    //        for (int i = 1; i <= noOfChild; i++)
    //        {
    //            if (i == 1)
    //            {
    //                divS8Child1.Visible = true;
    //                usrS8Child1DOB.IsEnableValidation(true);
    //            }
    //            if (i == 2)
    //            {
    //                divS8Child2.Visible = true;
    //                usrS8Child2DOB.IsEnableValidation(true);
    //            }
    //            if (i == 3)
    //            {
    //                divS8Child3.Visible = true;
    //                usrS8Child3DOB.IsEnableValidation(true);
    //            }
    //            if (i == 4)
    //            {
    //                divS8Child4.Visible = true;
    //                usrS8Child4DOB.IsEnableValidation(true);
    //            }
    //            if (i == 5)
    //            {
    //                divS8Child5.Visible = true;
    //                usrS8Child5DOB.IsEnableValidation(true);
    //            }
    //            if (i == 6)
    //            {
    //                divS8Child6.Visible = true;
    //                usrS8Child6DOB.IsEnableValidation(true);
    //            }
    //        }
    //    }

    //    //ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Init_JTIP", "JT_init();", true);
    //}

    #endregion oldcode

    //private bool SendMailToUser(Int64 RefCEUserId, bool IsExistingUser, string EmailAddress, string UserName, string DummyAuthCode)
    //{
    //    bool _retVal = false;
    //    if (CheckFirstTimeQuote(RefCEUserId))
    //    {
    //        //MyMailManager _mailMgr = new MyMailManager();
    //        string _emailTo = EmailAddress;
    //        string _customername = UserName;
    //        string _emailSubject = "First Travel Insurance Quote - " + CE.Global.General.GetUTCDateTime().ToString();
    //        string _mailBody = "";
    //        string _currentDomainUrl = "http://" + HttpContext.Current.Request.Url.Host.ToString();
    //        string imgLogoUrl = _currentDomainUrl + CE.Configuration.MyConfigurationManager.GetAppSettingValue("LogoPath");
    //        CompanyInformation _company = new CompanyInformation();
    //        CompanyInformationDB _companydb = new CompanyInformationDB();
    //        _company = _companydb.GetCompanyInformation(3);
    //        string _companyAddress = "";
    //        string _emailaddress = "";
    //        string _websiteaddress = "";
    //        if (_company != null)
    //        {
    //            _companyAddress = _company.Address1;
    //            _emailaddress = _company.EmailAddress;
    //            _websiteaddress = _company.Website;
    //        }
    //        _company = null;
    //        _companydb = null;

    //        _mailBody = "Dear " + _customername + ", <br /><br />Thank you for using CompareXpress Travel Insurance Comparison Engine for the first time.";
    //        if (!IsExistingUser)
    //        {
    //            _mailBody = ", <br /><br />Your account has been created — now it will be easier to compare and find the best travel insurance.";
    //            _mailBody += "<br /><br />You may now log in to <a href='http://www.comparexpress.com/' target='_blank'>http://www.comparexpress.com/</a> using the following username and password:";
    //            _mailBody += "<br /><br /> User Name : " + txtEmail.Text;
    //            _mailBody += "<br /> Password : " + DummyAuthCode;

    //        }
    //        _mailBody += "<br /><br />You are able to view this quote through our Members Area by clicking on the link below. <br /><br /> <a href='http://www.comparexpress.com' target='_blank'>http://www.comparexpress.com</a>.";
    //        _mailBody += "<br /><br /> Enter your Email and Password to login to the Members Area, located on the top right of the page.";

    //        _mailBody += "<br /><br />If you have any questions, comments, or feedback, please do not hesitate to contact us at <a href='mailto:support@comparexpress.com'>support@comparexpress.com</a>.";
    //        _mailBody += "<br /><br />Best Regards,<br /><br />Your CompareXpress Team<br/>Customer Support - SG/International";
    //        _mailBody += "<br /><img src='" + imgLogoUrl + "' />";
    //        _mailBody += "<br /><hr />";
    //        _mailBody += _companyAddress;
    //        _mailBody += "<br /><a href='" + _websiteaddress + "' target='_blank'>" + _websiteaddress + "</a> :: <a href='mailto:" + _emailaddress + "' target='_blank'>" + _emailaddress + "</a><br /><hr />";
    //        _mailBody += "<br /><i>This is a computer-generated email. Please do not reply to this email.</i>";
    //        if (MyMailManager.SendCRMMessage(_emailTo, _emailSubject, _mailBody))
    //        {
    //            _retVal = true;
    //        }
    //        else
    //        {
    //            _retVal = false;
    //        }
    //    }
    //    else
    //    {
    //        _retVal = true;
    //    }

    //    return _retVal;
    //}

    private bool CheckFirstTimeQuote(Int64 RefCEUserId)
    {
        MyDatabase _db = new MyDatabase();
        string _spName = "[sprocAutoEmailFirstQuoteInsertUpdateSingleItem]";

        SortedList _spList = new SortedList();
        _spList.Add("@RefCEUserId", RefCEUserId);
        _spList.Add("@EmailType", 300);
        Int64 _retValue = _db.ExecuteSP(_spName, _spList);
        return _retValue == 1;
    }

    private bool CheckTravelDateValid()
    {
        bool _IsValid = true;
        DateTime _Date = CE.Global.General.GetUTCDateTime();
        DateTime _TravelFromDate = CE.Global.General.GetUTCDateTime();
        DateTime _TravelToDate = CE.Global.General.GetUTCDateTime();

        if (ddlTripType.SelectedValue == "S")
        {

            string[] startdateformatted = Request.Form["from"].ToString().Trim().Split('/');
            string startdate = startdateformatted[2] + "-" + startdateformatted[1] + "-" + startdateformatted[0];

            string[] enddateformatted = Request.Form["to"].ToString().Trim().Split('/');
            string enddate = enddateformatted[2] + "-" + enddateformatted[1] + "-" + enddateformatted[0];

            DateTime dtStart = Convert.ToDateTime(startdate);
            DateTime dtEnd = Convert.ToDateTime(enddate);

            _TravelFromDate = dtStart; //usrTravelStartDate.GetDate();
            _TravelToDate = dtEnd; //usrTravelEndDate.GetDate();
        }

        if (_TravelFromDate >= _Date)
        {
            if (_TravelToDate >= _TravelFromDate)
            {
                _IsValid = true;
            }
            else
            {
                _IsValid = false;
            }
        }
        else
        {
            _IsValid = false;
        }
        return _IsValid;
    }

    private void ResultsQuotesDataBind()
    {
        if (Cache["TAResultsQuotes" + Session[General.TAId].ToString()] == null)
        GetTempResultTable();

        DataView dv = new DataView((DataTable)Cache["TAResultsQuotes" + Session[General.TAId].ToString()]);

        if (dv.Count > 0)
        {
            RowCount = dv.Count;

            if (Request.UrlReferrer != null)
            {
                Session["DefaultSort"] = null;
                Session["SortExp"] = null;

                dv.Sort = "AnnualPremium ASC";

                Cache["TAResultsQuotes" + Session[General.TAId].ToString()] = dv.ToTable();

            }

            string sQueryString = "";

            for (int i = 0; i < dv.ToTable().Rows.Count; i++)
            {
                if (i == 7)
                {
                    break;
                }

                string skey = dv.ToTable().Rows[i]["TAInsID"].ToString();
                sQueryString += skey + ",";
            }
            

            Session["TASelected"] = sQueryString;

        }

    }

    private void GetTempResultTable()
    {
        string CoverType = "";
        Int32 Duration = 0;
        string CoverageLevel = "";
        string Trip = "";
        Int64 AreaId = 0;
        Int64 CountryId = 0;
        Int32 AdultAge = 0;
        Int32 ChildAge = 0;
        Int64 TAId = 0;
        Int32 NoOfAdults = 0;
        Int32 NoOfChilds = 0;

        TAApplicantSearchDB _taapplicantsearchdb = new TAApplicantSearchDB();
        TAApplicantSearch _taapplicantsearch = new TAApplicantSearch();

        if (Session[General.TAId] != null && Session[General.TAId].ToString() != "")
            TAId = Convert.ToInt64(Session[General.TAId].ToString());
        else
        {
            this.Page_Load(this, null);
        }

        _taapplicantsearch = _taapplicantsearchdb.GetTAApplicantSearchItem(TAId);

        if (_taapplicantsearch != null)
        {
            //Response.Write("<script>window.alert('ok ')</script>");
            CoverType = _taapplicantsearch.PlanType;
            Duration = _taapplicantsearch.Duration;
            AreaId = _taapplicantsearch.AreaID;
            CountryId = _taapplicantsearch.CountryID;
            AdultAge = _taapplicantsearch.AdultAge;
            ChildAge = _taapplicantsearch.ChildAge;
            CoverageLevel = _taapplicantsearch.CoverageLevel;
            Trip = _taapplicantsearch.TripType;
            NoOfAdults = _taapplicantsearch.NoofAdults;
            NoOfChilds = _taapplicantsearch.NoofChilds;
            MyDatabase _db = new MyDatabase();
            DataTable _dtResult = new DataTable();


            TAQuoteResultDB _taquoteresultdb = new TAQuoteResultDB();

            if (Convert.ToInt32(Session[CE.Global.General.UserTypeId]) ==
             Convert.ToInt32(CE.Global.CEUserType.Provider) && Session[CE.Global.General.ProviderCompanyId] != null)
            {
                //Sakthi on 30 Dec 2010
                //_dtResult = _taquoteresultdb.GetTAQuoteResultDisplayByProvider(GetCovertype(CoverType), Duration.ToString(), AreaId, CountryId, AdultAge, ChildAge, CoverageLevel, Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString()), NoOfAdults);
                _dtResult = _taquoteresultdb.GetTAQuoteResultDisplayByProvider(GetCovertype(CoverType), Duration.ToString(), AreaId, CountryId, AdultAge, ChildAge, CoverageLevel, Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString()), NoOfAdults, NoOfChilds, TAId);

            }
            else if (_taapplicantsearch.Ninfo3 != 0)
            {
                //with Promo per Provider
                _dtResult = _taquoteresultdb.GetTAQuoteResultDisplayByProviderWithPromo(GetCovertype(CoverType), Duration.ToString(), AreaId, CountryId, AdultAge, ChildAge, CoverageLevel, _taapplicantsearch.Ninfo3, NoOfAdults, NoOfChilds, TAId);
            }
            else
            {

                //Sakthi on 30 Dec 2010
                //_dtResult = _taquoteresultdb.GetTAQuoteResultDisplay(GetCovertype(CoverType), Duration.ToString(), AreaId, CountryId, AdultAge, ChildAge, CoverageLevel, Trip, NoOfAdults);
                _dtResult = _taquoteresultdb.GetTAQuoteResultDisplay(GetCovertype(CoverType), Duration.ToString(), AreaId, CountryId, AdultAge, ChildAge, CoverageLevel, Trip, NoOfAdults, NoOfChilds, TAId);

            }
            // }

            RowCount = _dtResult.Rows.Count;

            DataView dv = new DataView(_dtResult);
            string strSortExpress = "AnnualPremium ASC";

            dv.Sort = strSortExpress;
            Cache["TAResultsQuotes" + Session[General.TAId].ToString()] = dv.ToTable();

        }
        else
        {
            this.Page_Load(this, null);

        }

    }

    private string GetCovertype(string covertype)
    {
        string coverparam = "";
        if (covertype == "IND")
            coverparam = "Individual";
        else if (covertype == "INS")
            coverparam = "IndividualSpouse";
        else if (covertype == "FML")
            coverparam = "Family";
        else if (covertype == "INC")
            coverparam = "IndividualChild";

        return coverparam;
    }
}

